<template>
  <div id="detailnavbar" >
    <nav-bar>
      <div slot="left"><img src="~assets/img/common/back.svg" alt="" @click="detailback" class="detailback"></div>
      <div slot="center" class="titles">
        <div v-for="(item,index) in titles" :key="index" class="titleslist">
          <div  @click="clickItem(index)" :class="{current : index == currentIndex}">{{item}}</div>
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>

import NavBar from 'components/common/navbar/NavBar.vue'

export default {
  name:'detailNavBar',
  components:{
    NavBar
  },
  data(){
    return{
      titles:['商品', '参数', '评论', '推荐'],
      currentIndex: 0
    }
  },
  methods:{
    detailback(){
      this.$router.back()
    },
    clickItem(index) {
      this.currentIndex = index;
      this.$emit('navClick', index)
    }
  }
}
</script>

<style scoped>
  .titles{
    font-size: 15px;
    display: flex;
  }

  .titleslist{
    flex: 1;
  }

  .detailback {
    padding-top: 12px;
  }

  .current{
    color: darkblue;
  }
</style>